package com.ruoyi.web.controller.eamp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.eamp.domain.EampReMan;
import com.ruoyi.eamp.domain.EampSrMan;
import com.ruoyi.eamp.service.IEampReManService;
import com.ruoyi.eamp.service.IEampSrManService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.eamp.domain.EampSrLog;
import com.ruoyi.eamp.service.IEampSrLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库房操作记录Controller
 *
 * @author ruoyi
 * @date 2024-08-09
 */
@RestController
@RequestMapping("/eamp/sr_log")
public class EampSrLogController extends BaseController
{
    @Autowired
    private IEampSrLogService eampSrLogService;

    @Autowired
    private IEampSrManService eampSrManService;

    @Autowired
    private IEampReManService eampReManService;

    @Autowired
    private ISysUserService userService;

    /**
     * 查询库房操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:sr_log:list')")
    @GetMapping("/list")
    public TableDataInfo list(EampSrLog eampSrLog)
    {
        startPage();
        List<EampSrLog> list = eampSrLogService.selectEampSrLogList(eampSrLog);
        return getDataTable(list);
    }
    /**
     * 导出库房操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:sr_log:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, EampSrLog eampSrLog)
    {
        List<EampSrLog> list = eampSrLogService.selectEampSrLogList(eampSrLog);
        ExcelUtil<EampSrLog> util = new ExcelUtil<EampSrLog>(EampSrLog.class);
        util.exportExcel(response, list, "库房操作记录数据");
    }
    /*
    * getUserById
    * */
    @GetMapping("/getUserList")
    public AjaxResult getUserList(){
        SysUser sysUser = new SysUser();
        return success(userService.selectUserList(sysUser));
    }
    /*
    * getSrById
    * */
    @GetMapping("/getSrList")
    public AjaxResult getSrList(){
        EampSrMan eampSrMan = new EampSrMan();
        return success(eampSrManService.selectEampSrManListAll(eampSrMan));
    }
    /*
    * 参试列表getReList
    * */
    @GetMapping("/getReList")
    public AjaxResult getReList(){
        EampReMan eampReMan = new EampReMan();
        return success(eampReManService.selectEampReManList(eampReMan));
    }
    /**
     * 获取库房操作记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('eamp:sr_log:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(eampSrLogService.selectEampSrLogByLogId(logId));
    }

    /**
     * 获取某个设备的详细信息
     */
    @GetMapping("/getReDetail")
    public AjaxResult getReDetail(@RequestParam("reId") Long reId)
    {
        return success(eampReManService.selectEampReManByReId(reId));
    }

    /**
     * 删除库房操作记录
     */
    @PreAuthorize("@ss.hasPermi('eamp:sr_log:remove')")
    @DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(eampSrLogService.deleteEampSrLogByLogIds(logIds));
    }
}
